// import { compose, curry } from "/nodeRmodules/lodash.js";
// import $ from "/nodeRmodules/jquery.js";

const trace = R.curry((tag, x) => {
  console.log(tag);
  return x;
});

// setHtml("body", $("<img />", { src: url }));
const setHtml = R.curry((sel, html) => $(sel).html(html));
const getJSON = R.curry((url) => {
  fetch(url)
    .then((response) => response.blob())
    .then((myBlob) => {
      let url = URL.createObjectURL(myBlob);
      console.log(url);
      return url;
    })
    .catch((err) => console.error(err));
});

var img = function (url) {
  console.log(url);
  return $("<img />", { src: url });
};

const url = (word) =>
  "http://placekitten.com/g/200/" + encodeURIComponent(word);

var app = R.compose(setHtml, img, getJSON, url);
app("300");
